package com.bianguo.android.functiondemo.view.activity;

import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.bianguo.android.functiondemo.R;
import com.bianguo.android.functiondemo.item.HeadItem;
import com.bianguo.android.functiondemo.item.NormalItem;
import com.bianguo.android.functiondemo.utils.MLog;
import com.zsd.android.recyclerviewlibrary.adapter.RViewAdapter;
import com.zsd.android.recyclerviewlibrary.listener.OnClickItemListener;
import com.zsd.android.recyclerviewlibrary.listener.RViewItem;

import java.util.ArrayList;

import butterknife.BindView;

public class RVActivity extends BaseRVActivity implements OnClickItemListener<String> {

    @BindView(R.id.rv_view)
    RecyclerView recyclerView;

    @Override
    public int layoutId() {
        return R.layout.activity_rv;
    }

    @Override
    public RecyclerView createRecyclerView() {
        return recyclerView;
    }

    @Override
    public RViewAdapter createAdapter() {
        ArrayList<String> list = new ArrayList<>();
        for (int i = 0; i < 40; i++) {
            list.add("item ---> " + i);
        }
        RViewAdapter adapter = new RViewAdapter(list);
        HeadItem headItem = new HeadItem();
        headItem.setOnClickItemListener(this);
        adapter.addItem(headItem);
        NormalItem normalItem = new NormalItem();
        normalItem.setOnClickItemListener(this);
        adapter.addItem(normalItem);
        return adapter;
    }

    @Override
    public void onClickItem(RViewItem item, View view, String data, int position) {
        MLog.mLog("data = " + data + ", position = " + position);
    }
}
